import { mapState } from 'vuex';

export default {
    computed: {
        ...mapState({
            _perssions: 'availablePermission'
        }),
        currentRights(){
            let menuCode = this.$route.params.menuCode || window.sessionStorage.getItem('wn_menuCode');
            let fMenu = this._perssions.find(p=>p.menuCode === menuCode);
            if( !fMenu ) {
                fMenu = {rights: '[0, 0, 0, 0]'};
            }
            let rights = JSON.parse(JSON.stringify(fMenu.rights));
            return JSON.parse(rights);
        }
    },
    methods: {
        checkPermission(index){
            // console.info(typeof this.currentRights);
            return !Boolean(+this.currentRights[ index ]);
        }
    },
}